package Thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-07-29
 * Time: 20:58
 */
public class demo9 {
    private static boolean flg = false;

    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while (!flg) {
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("t 线程执行结束");
        });

        t.start();
        System.out.println("main线程尝试终止t线程");
        flg = true;
    }
}
